﻿<UserControl x:Class="XWord.GUI.Views.Words.WordRelateEtymaView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:XWord.GUI.Views.Words"
             xmlns:cal="http://www.caliburnproject.org"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Expander IsExpanded="True"                    
                              Header="{Binding DataContext.DisplayName,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:WordRelateEtymaView}}}"
                              DataContext="{Binding SelectedWord,Source={cal:Resolve Key=WordExplorer}}">
        <ListBox DisplayMemberPath="Name" MinHeight="100" MaxHeight="200"
             ItemsSource="{Binding DataContext.EtymaLibraryList,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:WordRelateEtymaView}}}">
            <ListBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Margin" Value="0,0,0,5"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <TreeView>
                                            <TreeViewItem IsExpanded="True"
                                                            DisplayMemberPath="Name"
                                                            Header="{Binding Name}" ItemsSource="{Binding Items}">
                                                <TreeViewItem.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock HorizontalAlignment="Left" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" 
                                                                    Text="{Binding Name}" ToolTip="{Binding Comment}"/>
                                                    </DataTemplate>
                                                </TreeViewItem.ItemTemplate>
                                            </TreeViewItem>
                                        </TreeView>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListBox.GroupStyle>
        </ListBox>
    </Expander>
  
</UserControl>
